/*
 * @Author: szx
 * @Date: 2022-02-26 12:34:39
 * @LastEditTime: 2022-02-26 12:44:49
 * @Description:
 * @FilePath: \leetcode\1000-1099\1046\1046.js
 */
/**
 * @param {number[]} stones
 * @return {number}
 */
var lastStoneWeight = function (stones) {
    // 排序
    stones.sort((a, b) => a - b);
    let cha;
    let len = stones.length - 1;
    for (let i of stones) {
        len--;
        stones[len] = stones[len] - stones.pop();
    }
    return stones[0];
};
